{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "mylist = ['一', '二','三', '四']\n",
    "for i in mylist:\n",
    "  print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "books = {'标题': 'Python一学就会', '作者': '小明'}\n",
    "for k, v in books.items():\n",
    "    print(k, v)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i, v in enumerate(mylist):\n",
    "    print(i, v)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(1,10,2):\n",
    "    print(i)   "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "count = 1\n",
    "\n",
    "while count < 10:\n",
    "    print(count)\n",
    "    count += 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "xueji = ['gansu','zhejiang','hainan','shandong','gansu','zhejiang','hainan','shandong','gansu','zhejiang','hainan','shandong']\n",
    "for i, v in enumerate(xueji):\n",
    "  if v=='zhejiang':\n",
    "    print(f'第{i}个的值是{v}')\n",
    "    break\n",
    "print('这是循环体之外的语句')\n",
    "    # print('第',i,'个的值是')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "xueji = ['gansu','zhejiang','hainan','shandong','gansu','zhejiang','hainan','shandong','gansu','zhejiang','hainan','shandong']\n",
    "for i, v in enumerate(xueji):\n",
    "  if v=='zhejiang':\n",
    "    print(f'第{i}个的值是{v}')\n",
    "    continue\n",
    "print('这是循环体之外的语句')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def sayHello(name,message='你好'):\n",
    "  print(f'{name},{message}')\n",
    "sayHello('小明','你好！')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sayHello('小明')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sayHello('小丽','走！')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def scoreLevel(score):\n",
    "  if score>=85:\n",
    "    return 'A'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "result = scoreLevel(90)\n",
    "print(scoreLevel(90))\n",
    "print(result)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Person:\n",
    "\n",
    "      # 构造函数\n",
    "      def __init__(self, name):\n",
    "            self.name = name\n",
    "      # 定义属性\n",
    "      age = 20\n",
    "      # 定义方法\n",
    "      def whoami(self):\n",
    "           return f\"You are {self.name}\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "p1 = Person('tom')\n",
    "print(p1.whoami())\n",
    "print(p1.name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print(p1.age)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "xiaoming = Person('小明')\n",
    "xiaoming.age = 18\n",
    "print(xiaoming.age)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import myModule\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "这是一条来自于模块myModule的信息\n"
     ]
    }
   ],
   "source": [
    "myModule.hello()"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "11f1dc213e07634baa4c5c321dec03c05dafae643c50f20e6d1a492290c05dc2"
  },
  "kernelspec": {
   "display_name": "Python 3.9.7 64-bit",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
